package mil.af.amc.adpetracker.web.helpers;

import mil.af.amc.adpetracker.model.HandReceipt;
import mil.af.amc.adpetracker.service.HandReceiptService;
import mil.af.amc.radtaglibrary.tags.PageContextAwareBean;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.PageContext;
import java.util.List;


/**
 * Please fill in this Javadoc
 *
 * @author TSgt Ferguson
 */
@Service("handReceiptViewHelper")
public class HandReceiptViewHelper implements PageContextAwareBean {

    private PageContext pageContext;

    @Autowired
    public void setPageContext(PageContext pageContext) {
        this.pageContext = pageContext;
    }

    private HandReceiptService handReceiptService;

    @Autowired
    public void setHandReceiptService(HandReceiptService handReceiptService) {
        this.handReceiptService = handReceiptService;
    }

    private int adpeAccountId;

    public void setAdpeAccountId(int adpeAccountId) {
        this.adpeAccountId = adpeAccountId;
    }

    private int userId;

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public List<HandReceipt> getAll() {

        return handReceiptService.getAll();
    }

    public List<HandReceipt> getAllByAdpeAccount() {

        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
        int accountId = (Integer) request.getSession().getAttribute("accountId");
        return handReceiptService.getAllByAdpeAccount(accountId);

    }

    public List<HandReceipt> getAllByUser() {

        return handReceiptService.getAllByUser(userId);
        
    }
}
